package com.baidu.mpks.user.vo;

import com.baidu.mpks.role.domain.Role;
import com.baidu.mpks.usergroup.dto.Resources;
import com.baidu.mpks.util.Phone;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Data
public class UserParam {

    public static final String STATUS_INVALID = "Close";
    public static final String STATUS_VALID = "Open";
    private Integer id;
    private String userId;
    private String roleIds;
    private String userSecurity;
    private List<Role> roleList;
    private List<Resources> userInheritRoles;
    @NotBlank(
            message = "{user.name.empty}"
    )
    @Length(
            max = 25
    )
    private String userName;
    @NotBlank(
            message = "{true.name.empty}"
    )
    @Length(
            max = 25
    )
    private String trueName;
    private String gender;
    @Email(
            message = "{email.invalid}"
    )
    private String email;
    @Phone
    private String phoneNumber;
    private String status;
    private String avatar;
    private String code;
    private Integer isActive;
    private Integer adminPermission;
    private String adminUrl;
    private String createBy;
    private String updateBy;
    private String deptName;
    private Integer deptId;
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "GMT+8"
    )
    private Date createTime;
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss",
            timezone = "GMT+8"
    )
    private Date updateTime;
    private Map<String, Object> userInfo;

    public UserParam(String createBy, String updateBy) {
        this.setCreateBy(this.userId);
        this.setUpdateBy(this.userId);
    }

    public UserParam(String userId) {
        this(userId, userId);
    }

    public UserParam() {
    }
}
